<?php
  require_once('scripts/restrict_access.php');
  require_once('scripts/processLabels.php');
  require_once('scripts/library.php');
  
  if ($identity->accessLevel>20){
	header('Location: AccessDenied.php');
	exit;
}
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--

Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Title      : Complimentary
Version    : 1.0
Released   : 20080409
Description: A two-column, fixed-width and lightweight template ideal for 1024x768 resolutions. Suitable for blogs and small websites.

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Manage Label</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="CSS/ComplementaryDefault.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
    <h1><a href="#">Find-it</a>
</h1></div>
  <div id="menu">
    <div id="buttons">
  <ul>
    <li class="active"><a href="DBList.php"> Catalogs</a></li>
    <li><a href="EditContainerForm.php">New container
    </a></li>
    <li><a href="ManageLabels.php">Labels</a></li>
    <li><a href="EditItemForm.php">New Item</a></li>
    <li><a href="Index.php?logout">Logout </a></li>
  </ul>
    </div>
  </div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
  <!-- start content -->
  <div id="content">
    <div class="post">
      <p><br />
      </p>     
      <div class="searchfield">
        <form method="get" action="SearchResults.php?">
    <fieldset>
      <input name="searchtext" type="text" id="s" value="" />
      <input name="dbId" type="hidden" value="<?php echo $_GET['dbId'];?>" />
      <input type="submit" id="x" value="Search" />
      </fieldset>
  </form>
</div><br/>      
      <h1 class="title">Manage Labels</h1>
      <div class="searchfield"></div>
      <div class="entry">
        <form id="form1" method="post" action="">
          <span class="warning">
           <?php
           if ($_POST && isset($errors['labelNameInvalid'])){
			   echo $errors['labelNameInvalid'];
		   }
           if ($_POST && isset($errors['labelNameDuplicate'])){
			   echo $errors['labelNameDuplicate'];
		   } ?>
          </span>

<label for="labelName">
           Label Name:</label>
          <input name="labelName" type="text" id="labelName" size="50" maxlength="50"
          value="<?php if ($_POST && $errors){
			  echo htmlentities($_POST['labelName'],ENT_COMPAT, 'UTF-8');
		  }?>"/>
          <br />

           <span class="warning">
           <?php
           if ($_POST && isset($errors['labelDescriptionInvalid']))
		   {
			  echo $errors['labelDescriptionInvalid'];
		   }?>
          </span>

<label for="labelDescription">
           Label Description:</label>
          <input name="labelDescription" type="text" id="labelDescription" size="50" maxlength="100"
          value="<?php if ($_POST && $errors){
			  echo htmlentities($_POST['labelDescription'],ENT_COMPAT, 'UTF-8');
		  }?>"/>

          <br />
          <input type="submit" name="addLabel" id="addLabel" value="Add Label" />
          <br />
          
          
        </form>
      <p><br /><br />
      </p> 

          <h2 class="tableLabel"> Labels </h2>     
  <table width="100%" border="1" cellspacing="3" cellpadding="3">        
  <tr>
    <td width="25%"><h3>Name</h3></td>
    <td width="65%"><h3>Description</h3></td>
    <td width="10%"><h3>Delete</h3></td>
  </tr>
  <?php 
  		    $sql = 'SELECT labelId,labelName,labelDescription FROM `labels` WHERE accountId = ?';
  $result = $dbRead->fetchAll($sql,$_SESSION['accountId']);
  $size_of_result = sizeof($result);
  
  for ($i=0; $i<$size_of_result; $i++){ ?>
  <tr>
    <td><?php echo $result[$i]['labelName'];?></td>
    <td><?php echo $result[$i]['labelDescription']; ?></td>
    <td><a href="scripts/process_delete_label.php?labelId=<?php echo $result[$i]['labelId']?>">Delete</a></td>
  </tr><?php } ?>  
</table>
          
        
        <!-- The bottomSpace div is for reserving space at the bottom for the footer -->
        <div class="bottomSpace">
          <p><br /><br />
          </p>
        </div>
      </div>
      
    </div>
  </div>
  <!-- end content -->
  <!-- start sidebar --><!-- end sidebar -->
  <div style="clear: both;">&nbsp;</div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
  <p id="legal">(c) 2012 Find-It. Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.<br />
	</p>
</div>
<!-- end footer -->
</body>
</html>
